package xkp.lesson.ui;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;

public class MainUi extends JFrame {

    public MainUi() {
        //窗体大小
        this.setSize(800, 300);
        //设置窗体大小不可改变
        this.setResizable(false);

        //可以退出
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        //相对屏幕居中
        this.setLocationRelativeTo(null);
        //窗体名字
        this.setTitle("爬虫项目");

        //流式布局
        FlowLayout flow = new FlowLayout();
        this.setLayout(flow);

        JButton showReadJobBtn = new JButton("爬取数据");
        showReadJobBtn.setFont(new Font("黑体", Font.BOLD, 40));
        showReadJobBtn.setPreferredSize(new Dimension(300, 240));
        this.add(showReadJobBtn);
        showReadJobBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                new ReadJobUi();
            }
        });

        JButton managerJobBtn = new JButton("管理数据");
        managerJobBtn.setPreferredSize(new Dimension(300, 240));
        managerJobBtn.setFont(new Font("黑体", Font.BOLD, 40));
        this.add(managerJobBtn);
        managerJobBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                try {
                    new ManagerJobUi();
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
        });
        this.setVisible(true);

    }
}
